Last updated: 2025-02-20
Checks: 5 2
Knit directory: SPP1_mouse_scRNAseq/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
The R Markdown is untracked by Git. To know which version of the R
Markdown file created these results, you’ll want to first commit it to
the Git repo. If you’re still working on the analysis, you can ignore
this warning. When you’re finished, you can run
wflow_publish to commit the R Markdown file and build the
HTML.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20250102) was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.
| absolute | relative |
|---|---|
| /home/hnatri/SPP1_mouse_scRNAseq/ | . |
| /home/hnatri/SPP1_mouse_scRNAseq/code/CART_plot_functions.R | code/CART_plot_functions.R |
| /home/hnatri/SPP1_mouse_scRNAseq/code/colors_themes.R | code/colors_themes.R |
| /home/hnatri/SPP1_mouse_scRNAseq/myeloid_cluster_markers.tsv | myeloid_cluster_markers.tsv |
| /home/hnatri/SPP1_mouse_scRNAseq/lymphoid_cluster_markers.tsv | lymphoid_cluster_markers.tsv |
| /home/hnatri/SPP1_mouse_scRNAseq/analysis/analyze_compartments.Rmd | analysis/analyze_compartments.Rmd |
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 84ba8d7. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish or
wflow_git_commit). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: analysis/figure/
Untracked files:
Untracked: analysis/analyze_compartments.Rmd
Untracked: lymphoid_cluster_markers.tsv
Untracked: myeloid_cluster_markers.tsv
Unstaged changes:
Modified: Rplots.pdf
Modified: analysis/first_pass.Rmd
Modified: code/colors_themes.R
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
There are no past versions. Publish this analysis with
wflow_publish() to start tracking its development.
library(workflowr)
library(Seurat)
library(googlesheets4)
library(tidyverse)
library(plyr)
library(ggrepel)
library(patchwork)
setwd("/home/hnatri/SPP1_mouse_scRNAseq/")
set.seed(1234)
options(future.globals.maxSize = 30000 * 1024^2)
reduction <- "umap"
source("/home/hnatri/SPP1_mouse_scRNAseq/code/CART_plot_functions.R")
source("/home/hnatri/SPP1_mouse_scRNAseq/code/colors_themes.R")
source("/home/hnatri/SingleCellBestPractices/scripts/preprocessing_qc_module.R")
source("/home/hnatri/SingleCellBestPractices/scripts/integration_module.R")
# Cluster annotations
gs4_deauth()
annot <- gs4_get("https://docs.google.com/spreadsheets/d/127J6C4KF7uBGKUnrPuC1mcsb_wNCN6k1zXKSCbJ6q0M/edit?usp=sharing")
cluster_annot <- read_sheet(annot, sheet = "Cluster annotation")
myeloid_annot <- read_sheet(annot, sheet = "Myeloid annotation")
lymphoid_annot <- read_sheet(annot, sheet = "Lymphoid annotation")
recluster_seurat <- function(seurat_object, vars_to_regress){
DefaultAssay(seurat_object) <- "RNA"
seurat_object <- SCTransform(seurat_object, vars.to.regress = vars_to_regress)
seurat_object <- RunPCA(seurat_object,
reduction.name = "pca",
verbose = F)
pcs <- get_pcs(seurat_object, reduction_name = "pca")
message(pcs)
seurat_object <- RunUMAP(seurat_object,
reduction = "pca",
reduction.name = "umap",
dims = 1:min(pcs),
return.model = TRUE)
seurat_object <- FindNeighbors(seurat_object,
reduction = "pca",
dims = 1:min(pcs),
graph.name = c("nn",
"snn"))
seurat_object <- FindClusters(seurat_object,
resolution = c(0.1,0.2,0.3,0.5,0.8,1),
graph.name = "snn")
return(seurat_object)
}
seurat_data <- readRDS("/tgen_labs/banovich/BCTCSF/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8.rds")
unique(seurat_data$orig.ident)
unique(seurat_data$annot)
vars_to_regress <- c("G2M.Score",
"S.Score",
"nCount_RNA",
"nFeature_RNA",
"percent.mt")
myel_cells <- grep("^M", unique(seurat_data$annot), value = T)
myeloid <- subset(seurat_data, subset = annot %in% myel_cells)
myeloid <- recluster_seurat(myeloid, vars_to_regress)
#saveRDS(myeloid, "/scratch/hnatri/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_myeloid.rds")
myeloid <- readRDS("/scratch/hnatri/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_myeloid.rds")
DimPlot(myeloid,
group.by = "annot",
cols = myeloid_colors,
reduction = reduction,
label = T,
label.box = T,
label.size = 3,
repel = T,
raster = T,
raster.dpi = c(1024, 1024),
pt.size = 3) +
ggtitle("") +
theme_classic() +
NoLegend() +
NoAxes() +
coord_fixed(1)
DimPlot(myeloid,
group.by = "snn_res.0.3",
cols = myeloid_cluster_col,
reduction = reduction,
label = T,
label.box = T,
label.size = 3,
repel = T,
raster = T,
raster.dpi = c(1024, 1024),
pt.size = 3) +
ggtitle("") +
theme_classic() +
NoLegend() +
NoAxes() +
coord_fixed(1)
markers <- presto::wilcoxauc(myeloid,
group_by = "snn_res.0.3",
assay = "data",
seurat_assay = "RNA_human")
plot_features <- markers %>% group_by(group) %>% slice_max(order_by = auc, n = 5)
DefaultAssay(myeloid) <- "RNA_human"
create_dotplot_heatmap(seurat_object = myeloid,
plot_features = unique(plot_features$feature),
group_var = "snn_res.0.3",
group_colors = myeloid_cluster_col,
column_title = "",
row_km = 5,
col_km = 5,
row.order = NULL,
col.order = NULL)
plot_features <- c("PTMA", "PFN1", "CFL1", "TMSB4X", "TPT1", "TMSB10", "MIF",
"PDPN", "NLRP3", "IL1B", "CCL4", "S100A8", "S100A9",
"S100A10", "TYROBP", "CD68", "ICAM1", "C1QA", "C1QB", "C1QC",
"CD74", "AREG", "CD4", "APOE", "FABP5", "SPP1", "CD274",
"CD96", "PTPRC", "CEMIP2", "KLRD1", "CD8A", "NKG7", "IL32",
"CD3D", "BTG1", "IFITM2", "ITM2A", "SELL", "GZMB", "CD79A",
"ACTA2", "PDGFRB", "COL1A1", "CD163", "MRC1", "ITGAM", "CD14",
"CD279", "PDCD1", "TREM2", "TMEM119", "P2RY12", "CX3CR1")
create_dotplot_heatmap(seurat_object = myeloid,
plot_features = plot_features,
group_var = "snn_res.0.3",
group_colors = myeloid_cluster_col,
column_title = "",
row_km = 5,
col_km = 5,
row.order = NULL,
col.order = NULL)
FeaturePlot(myeloid,
#layer = "RNA",
slot = "data",
features = plot_features,
order = T,
ncol = 5,
reduction = reduction,
raster = T,
cols = c("gray89", "tomato3")) &
coord_fixed(ratio = 1) &
theme_bw() &
NoLegend()
output_cluster_markers <- markers %>%
arrange(dplyr::desc(logFC)) %>%
group_by(group) %>%
dplyr::slice(1:30)
write.table(output_cluster_markers, "/home/hnatri/SPP1_mouse_scRNAseq/myeloid_cluster_markers.tsv",
quote = F, row.names = F, sep = "\t")
myeloid$myeloid_annot <- mapvalues(x = myeloid$snn_res.0.3,
from = myeloid_annot$snn_res.0.3,
to = myeloid_annot$annot)
DimPlot(myeloid,
group.by = "myeloid_annot",
#cols = carspp1_celltype_col,
reduction = reduction,
label = T,
label.box = T,
label.size = 3,
repel = T,
raster = T,
raster.dpi = c(1024, 1024),
pt.size = 3) +
ggtitle("") +
theme_classic() +
NoLegend() +
NoAxes() +
coord_fixed(1)
seurat_data$myeloid_annot <- mapvalues(x = rownames(seurat_data@meta.data),
from = rownames(myeloid@meta.data),
to = as.character(myeloid$annot))
seurat_data@meta.data$myeloid_annot[-which(rownames(seurat_data@meta.data) %in% rownames(myeloid@meta.data))] <- NA
seurat_data$annot_granular <- ifelse(!is.na(seurat_data$myeloid_annot),
seurat_data$myeloid_annot,
seurat_data$annot)
unique(seurat_data$annot_granular)
[1] "3" "6" "M1_suppressive"
[4] "5" "11" "12"
[7] "M6" "M9" "M2_suppressive"
[10] "14" "M4" "M5_suppressive"
[13] "M7" "M3_suppressive" "M8_suppressive_G2MS"
[16] "M10" "M11"
#DimPlot(seurat_data,
# group.by = "annot_granular",
# #cols = carspp1_celltype_col,
# reduction = "integratedSCTumap",
# label = T,
# label.box = T,
# label.size = 3,
# repel = T,
# raster = T,
# raster.dpi = c(1024, 1024),
# pt.size = 3) +
# ggtitle("") +
# theme_classic() +
# NoLegend() +
# NoAxes() +
# coord_fixed(1)
#saveRDS(myeloid, "/tgen_labs/banovich/BCTCSF/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_myeloid.rds")
vars_to_regress <- c("G2M.Score",
"S.Score",
"nCount_RNA",
"nFeature_RNA",
"percent.mt")
lymph_cells <- grep("^L", unique(seurat_data$annot), value = T)
lymphoid <- subset(seurat_data, subset = annot %in% lymph_cells)
lymphoid <- recluster_seurat(lymphoid, vars_to_regress)
#saveRDS(lymphoid, "/scratch/hnatri/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_lymphoid.rds")
lymphoid <- readRDS("/scratch/hnatri/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_lymphoid.rds")
#DimPlot(lymphoid,
# group.by = "annot",
# cols = lymphoid_cluster_col,
# reduction = reduction,
# label = T,
# label.box = T,
# label.size = 3,
# repel = T,
# raster = T,
# raster.dpi = c(1024, 1024),
# pt.size = 3) +
# ggtitle("") +
# theme_classic() +
# NoLegend() +
# NoAxes() +
# coord_fixed(1)
DimPlot(lymphoid,
group.by = "snn_res.0.3",
cols = lymphoid_cluster_col,
reduction = reduction,
label = T,
label.box = T,
label.size = 3,
repel = T,
raster = T,
raster.dpi = c(1024, 1024),
pt.size = 3) +
ggtitle("") +
theme_classic() +
NoLegend() +
NoAxes() +
coord_fixed(1)
markers <- presto::wilcoxauc(lymphoid,
group_by = "snn_res.0.3",
assay = "data",
seurat_assay = "RNA_human")
plot_features <- markers %>% group_by(group) %>% slice_max(order_by = auc, n = 5)
DefaultAssay(lymphoid) <- "RNA_human"
create_dotplot_heatmap(seurat_object = lymphoid,
plot_features = unique(plot_features$feature),
group_var = "snn_res.0.3",
group_colors = lymphoid_cluster_col,
column_title = "",
row_km = 5,
col_km = 5,
row.order = NULL,
col.order = NULL)
plot_features <- c("PTMA", "PFN1", "CFL1", "TMSB4X", "TPT1", "TMSB10", "MIF",
"PDPN", "NLRP3", "IL1B", "CCL4", "S100A8", "S100A9",
"S100A10", "TYROBP", "CD68", "ICAM1", "C1QA", "C1QB", "C1QC",
"CD74", "AREG", "CD4", "APOE", "FABP5", "SPP1", "CD274",
"CD96", "PTPRC", "CEMIP2", "KLRD1", "CD8A", "NKG7", "IL32",
"CD3D", "BTG1", "IFITM2", "ITM2A", "SELL", "GZMB", "CD79A",
"ACTA2", "PDGFRB", "COL1A1", "CD163", "MRC1", "ITGAM", "CD14",
"CD279", "PDCD1", "TREM2", "TMEM119", "P2RY12", "CX3CR1")
create_dotplot_heatmap(seurat_object = lymphoid,
plot_features = plot_features,
group_var = "snn_res.0.3",
group_colors = lymphoid_cluster_col,
column_title = "",
row_km = 5,
col_km = 5,
row.order = NULL,
col.order = NULL)
FeaturePlot(lymphoid,
#layer = "RNA",
slot = "data",
features = plot_features,
order = T,
ncol = 5,
reduction = reduction,
raster = T,
cols = c("gray89", "tomato3")) &
coord_fixed(ratio = 1) &
theme_bw() &
NoLegend()
output_cluster_markers <- markers %>%
arrange(dplyr::desc(logFC)) %>%
group_by(group) %>%
dplyr::slice(1:30)
write.table(output_cluster_markers, "/home/hnatri/SPP1_mouse_scRNAseq/lymphoid_cluster_markers.tsv",
quote = F, row.names = F, sep = "\t")
lymphoid$lymphoid_annot <- mapvalues(x = lymphoid$snn_res.0.3,
from = lymphoid_annot$snn_res.0.3,
to = lymphoid_annot$annot)
DimPlot(lymphoid,
group.by = "lymphoid_annot",
#cols = carspp1_celltype_col,
reduction = reduction,
label = T,
label.box = T,
label.size = 3,
repel = T,
raster = T,
raster.dpi = c(1024, 1024),
pt.size = 3) +
ggtitle("") +
theme_classic() +
NoLegend() +
NoAxes() +
coord_fixed(1)
unique(lymphoid$annot)
[1] L1_CD4 L2_CD8 L3_CD4_G2MS L4_lowerQ L5_lowerQ
17 Levels: M1_suppressive M2_suppressive L1_CD4 M3_suppressive L2_CD8 NK ... M11
seurat_data$lymphoid_annot <- mapvalues(x = rownames(seurat_data@meta.data),
from = rownames(lymphoid@meta.data),
to = as.character(lymphoid$annot))
seurat_data@meta.data$lymphoid_annot[-which(rownames(seurat_data@meta.data) %in% rownames(lymphoid@meta.data))] <- NA
unique(seurat_data$lymphoid_annot)
[1] "L1_CD4" NA "L2_CD8" "L3_CD4_G2MS" "L4_lowerQ"
[6] "L5_lowerQ"
seurat_data$annot_granular <- ifelse(!is.na(seurat_data$lymphoid_annot),
as.character(seurat_data$lymphoid_annot),
as.character(seurat_data$annot))
unique(seurat_data$annot_granular)
[1] "L1_CD4" "NK" "M1_suppressive"
[4] "L2_CD8" "L3_CD4_G2MS" "L4_lowerQ"
[7] "M6" "M9" "M2_suppressive"
[10] "L5_lowerQ" "M4" "M5_suppressive"
[13] "M7" "M3_suppressive" "M8_suppressive_G2MS"
[16] "M10" "M11"
#DimPlot(seurat_data,
# #group.by = "annot_granular",
# #cols = carspp1_celltype_col,
# reduction = "integratedSCTumap",
# label = T,
# label.box = T,
# label.size = 3,
# repel = T,
# raster = T,
# raster.dpi = c(1024, 1024),
# pt.size = 3) +
# ggtitle("") +
# theme_classic() +
# NoLegend() +
# NoAxes() +
# coord_fixed(1)
#saveRDS(lymphoid, "/tgen_labs/banovich/BCTCSF/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_lymphoid.rds")
saveRDS(seurat_data, "/tgen_labs/banovich/BCTCSF/SPP1_mouse_scRNAseq/scRNAseq_Seurat_dim8_annotated.rds")
# To build on command line, run Rscript -e "rmarkdown::render('/home/hnatri/SPP1_mouse_scRNAseq/analysis/analyze_compartments.Rmd')"
# Then "mv *.html /home/hnatri/SPP1_mouse_scRNAseq/docs/"
sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats4 grid stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] mclust_6.0.0 scCustomize_1.1.1
[3] glmGamPoi_1.14.3 DoubletFinder_2.0.4
[5] scater_1.30.1 scuttle_1.12.0
[7] SingleCellExperiment_1.24.0 SummarizedExperiment_1.32.0
[9] Biobase_2.62.0 GenomicRanges_1.54.1
[11] GenomeInfoDb_1.38.5 IRanges_2.36.0
[13] S4Vectors_0.40.2 BiocGenerics_0.48.1
[15] MatrixGenerics_1.14.0 matrixStats_1.0.0
[17] SoupX_1.6.2 circlize_0.4.15
[19] ComplexHeatmap_2.18.0 viridis_0.6.3
[21] viridisLite_0.4.2 RColorBrewer_1.1-3
[23] patchwork_1.1.2 ggrepel_0.9.3
[25] plyr_1.8.8 lubridate_1.9.2
[27] forcats_1.0.0 stringr_1.5.0
[29] dplyr_1.1.2 purrr_1.0.1
[31] readr_2.1.4 tidyr_1.3.0
[33] tibble_3.2.1 ggplot2_3.4.2
[35] tidyverse_2.0.0 googlesheets4_1.1.0
[37] Seurat_5.0.1 SeuratObject_5.0.1
[39] sp_1.6-1 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] fs_1.6.2 spatstat.sparse_3.0-1
[3] bitops_1.0-7 httr_1.4.6
[5] doParallel_1.0.17 tools_4.3.0
[7] sctransform_0.4.1 utf8_1.2.3
[9] R6_2.5.1 lazyeval_0.2.2
[11] uwot_0.1.14 GetoptLong_1.0.5
[13] withr_2.5.0 gridExtra_2.3
[15] progressr_0.13.0 cli_3.6.1
[17] Cairo_1.6-0 spatstat.explore_3.2-1
[19] fastDummies_1.7.3 labeling_0.4.2
[21] sass_0.4.6 spatstat.data_3.0-1
[23] ggridges_0.5.4 pbapply_1.7-0
[25] parallelly_1.36.0 rstudioapi_0.14
[27] generics_0.1.3 shape_1.4.6
[29] ica_1.0-3 spatstat.random_3.1-5
[31] Matrix_1.6-5 ggbeeswarm_0.7.2
[33] fansi_1.0.4 abind_1.4-5
[35] lifecycle_1.0.3 whisker_0.4.1
[37] yaml_2.3.7 snakecase_0.11.0
[39] SparseArray_1.2.3 Rtsne_0.16
[41] paletteer_1.5.0 promises_1.2.0.1
[43] crayon_1.5.2 miniUI_0.1.1.1
[45] lattice_0.21-8 beachmat_2.18.1
[47] cowplot_1.1.1 magick_2.7.4
[49] pillar_1.9.0 knitr_1.43
[51] rjson_0.2.21 future.apply_1.11.0
[53] codetools_0.2-19 leiden_0.4.3
[55] glue_1.6.2 getPass_0.2-4
[57] data.table_1.14.8 vctrs_0.6.2
[59] png_0.1-8 spam_2.9-1
[61] cellranger_1.1.0 gtable_0.3.3
[63] rematch2_2.1.2 cachem_1.0.8
[65] xfun_0.39 S4Arrays_1.2.0
[67] mime_0.12 survival_3.5-5
[69] gargle_1.4.0 iterators_1.0.14
[71] ellipsis_0.3.2 fitdistrplus_1.1-11
[73] ROCR_1.0-11 nlme_3.1-162
[75] RcppAnnoy_0.0.20 rprojroot_2.0.3
[77] bslib_0.4.2 irlba_2.3.5.1
[79] vipor_0.4.5 KernSmooth_2.23-21
[81] colorspace_2.1-0 ggrastr_1.0.2
[83] tidyselect_1.2.0 processx_3.8.1
[85] compiler_4.3.0 curl_5.0.0
[87] git2r_0.32.0 BiocNeighbors_1.20.2
[89] DelayedArray_0.28.0 plotly_4.10.2
[91] scales_1.2.1 lmtest_0.9-40
[93] callr_3.7.3 digest_0.6.31
[95] goftest_1.2-3 presto_1.0.0
[97] spatstat.utils_3.0-3 rmarkdown_2.22
[99] XVector_0.42.0 htmltools_0.5.5
[101] pkgconfig_2.0.3 sparseMatrixStats_1.14.0
[103] highr_0.10 fastmap_1.1.1
[105] rlang_1.1.1 GlobalOptions_0.1.2
[107] htmlwidgets_1.6.2 shiny_1.7.4
[109] DelayedMatrixStats_1.24.0 farver_2.1.1
[111] jquerylib_0.1.4 zoo_1.8-12
[113] jsonlite_1.8.5 BiocParallel_1.36.0
[115] BiocSingular_1.18.0 RCurl_1.98-1.12
[117] magrittr_2.0.3 GenomeInfoDbData_1.2.11
[119] dotCall64_1.0-2 munsell_0.5.0
[121] Rcpp_1.0.10 reticulate_1.29
[123] stringi_1.7.12 zlibbioc_1.48.0
[125] MASS_7.3-60 parallel_4.3.0
[127] listenv_0.9.0 deldir_1.0-9
[129] splines_4.3.0 tensor_1.5
[131] hms_1.1.3 ps_1.7.5
[133] igraph_1.4.3 spatstat.geom_3.2-1
[135] RcppHNSW_0.5.0 reshape2_1.4.4
[137] ScaledMatrix_1.10.0 evaluate_0.21
[139] ggprism_1.0.4 tzdb_0.4.0
[141] foreach_1.5.2 httpuv_1.6.11
[143] RANN_2.6.1 polyclip_1.10-4
[145] future_1.32.0 clue_0.3-64
[147] scattermore_1.2 rsvd_1.0.5
[149] janitor_2.2.0 xtable_1.8-4
[151] RSpectra_0.16-1 later_1.3.1
[153] googledrive_2.1.0 beeswarm_0.4.0
[155] cluster_2.1.4 timechange_0.2.0
[157] globals_0.16.2